package com.xique.door.listener;

import com.xique.door.constant.AccessCommandConstant;
import com.xique.door.device.command.AccessCommandHQService;
import com.xique.door.event.DelUserCommandEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author shd
 * @create 2021/7/3 10:17
 */
@Component
public class DelUserCommandListener implements ApplicationListener<DelUserCommandEvent> {


    @Autowired
    private AccessCommandHQService accessCommandService;

    /**
     *
     * @author shd
     * @date 2021/7/5 8:57
     * @param event 事件参数
     */
    @Override
    @Async
    public void onApplicationEvent(DelUserCommandEvent event) {
        Map<String, List<String>> map = new HashMap<>(1);
        map.put("customId", event.getCustomIds());
        Object o = accessCommandService.delBatchUserInfos(event.getDevSns(), map, AccessCommandConstant.VERSION);
        System.out.println("==========》用户删除：" + event.getDevSns() + "===========>" + event.getCustomIds() + "=============>" + o.toString());
    }
}
